#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "HttpClient.h"
#include "WallpaperModel.h"
#include "WindowsServiceHelper.h"
#include <QMainWindow>
#include <QMouseEvent>
#include <QTranslator>
#include <QDebug>
#include <QApplication>
#include <QLabel>
#include <QList>
#include <QDir>
#include <windows.h>
#include <Sstream>
#include <QPainter>
#include <iostream>
#include "FileHelper.h"
#include "WallpaperService.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
private:
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *);
    void InitialUI();
    void InitialSlot();
    void InitData();

private slots:

    void Previous();
    void Next();
    void SetAsWallpaper();
    void MiniMized()
    {
        this->showMinimized();
    }

    void DownloadImageFinish(QNetworkReply*,QString);

    void GetWallpaperFinished(QList<WallpaperModel *> papers);

    void SetWidgetImage(int index);

    void SaveImageList(QList<WallpaperModel*> papers);

private:

    Ui::MainWindow *ui;

    int currentPage;   //当前pageIndex
    int currentIndex;  //当前壁纸index
    const int countPerPage;  //每页壁纸数量
    bool moveStart; //鼠标移动
    bool nextStart;


    WallpaperService *service;
    HttpClient *httpClient;
    QPoint preMousePos;
    WallpaperModel *currentPaper;
    QList<WallpaperModel *> papers;
    QString currentImageName;
    QPainter *painter;
    QPixmap *pixmap;
    FileHelper fileHelper;
protected:
    void paintEvent(QPaintEvent *);
};

#endif // MAINWINDOW_H
